package com.sky.wsp.weixin.controller;

import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
import me.chanjar.weixin.cp.bean.message.WxCpMessage;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author wangshaopeng@talkweb.com.cn
 * @desccription 在此输入描述
 * @date 2023/6/2
 */
@RestController
@RequestMapping("/test")
public class TestController {
    @Resource
    private WxCpServiceImpl wxCpService;

    @GetMapping("/send/msg")
    public void sendMsg(String msg) {
        if(null == msg){
            msg = "拓维-王少鹏-测试验证码-6666";
        }
        WxCpMessage message = new WxCpMessage();
        message.setToUser("24044");
        message.setMsgType(WxConsts.KefuMsgType.TEXT);
        message.setContent(msg);
        try {
            wxCpService.getMessageService().send(message);
        } catch (WxErrorException e) {
            e.printStackTrace();
        }
    }
}
